
LICENSE = "GPLv2"
LIC_FILES_CHKSUM = "file://COPYING;md5=8c0323a6a5e94cd2a72b8fb935e90fcd"

inherit module

SRC_URI = "git://source.codeaurora.org/external/autobsps32/icc-linux;branch=alb/master;protocol=https"
SRC_URI += "file://0001-icc-change-shared-mem-reservation-due-to-conflict.patch"

export INSTALL_MOD_DIR="icc-linux"

DESTDIR="${D}"
export DESTDIR

LOCAL_CONFIGDIR ?= "output"
SRC_CONFIGDIR = "${THISDIR}/${LOCAL_CONFIGDIR}"
export SRC_CONFIGDIR

S = "${WORKDIR}/git"
DEST_CONFIGDIR="${S}/release/iccs32v234/sample/config/"
export DEST_CONFIGDIR

MODULES_MODULE_SYMVERS_LOCATION = "release/iccs32v234/sample/linux_app/ICC_Sample_module"

FILESEXTRAPATHS_prepend := "${SRC_CONFIGDIR}:"

INSTALL_PATH ?= "/opt/samples"

# ICC Configuration is generated by Tresos in the following tree structure:
# <icc_project>
#    output
#        include \ ICC_Config.h
#        src \ ICC_Config.c
# Users may simply copy the "output" folder into current directory, over existing
# "output" folder, in order to replace default configuration with a custom one.
SRC_URI += "\
    file://src/ICC_Config.c \
    file://include/ICC_Config.h \
"

do_configure() {
    # copy configuration files desired defconfig so we pick it up for the real kernel_do_configure
    cp -f "${SRC_CONFIGDIR}/src/ICC_Config.c" "${DEST_CONFIGDIR}/src/ICC_Config.c"
    cp -f "${SRC_CONFIGDIR}/include/ICC_Config.h" "${DEST_CONFIGDIR}/include/ICC_Config.h"
}

DESTDIR = "${D}${INSTALL_PATH}"

module_do_install() {
    # move the ICC modules from /lib/modules to prevent from being automatically loaded
    install -d ${DESTDIR}
    oe_runmake DEPMOD=echo MODLIB="${DESTDIR}" modules_install
}

FILES_${PN} += "${INSTALL_PATH}"
